package nix.proxy;

import org.junit.Test;

public class Demo3 {

	@Test
	public void fun1() {
		// 创建代理对象工厂
		ProxyFactory factory = new ProxyFactory();
		// 设置目标对象
		factory.setTargetObject(new ManWaiter());
		// 设置前置增强（实现）
		factory.setBeforeAdvice(new BeforeAdvice() {
			@Override
			public void before() {
				System.out.println("hello");
			}
		});
		// 设置后置增强（实现）
		factory.setAfterAdvice(new AfterAdvice() {
			@Override
			public void after() {
				System.out.println("bye");
			}
		});
		// 生成代理对象
		Waiter manWaiter = (Waiter) factory.createProxy();
		manWaiter.serve();
	}
}
